<?php
class PNVillagePollArray extends PNObjectArray {
  function PNVillagePollArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'votethailandpoll_villagepoll';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';

    $this->_objJoin[]     = array ( 'join_table'          =>  'votethailandpoll_house_no',
                                    'join_field'          =>  array('no', 'latitude', 'longitude'),
                                    'object_field_name'   =>  array('house_no', 'latitude', 'longitude'),
                                    'compare_field_table' =>  'house_no_id',
                                    'compare_field_join'  =>  'id');
                            

    $this->objJoin[]      = array('join_table'            => 'votethailandpoll_party',
                                  'join_field'            => array('id','name'),
                                  'object_field_name'     => array('party_id','party_name'),
                                  'compare_field_table'   => 'par_id',
                                  'compare_field_join'    => 'id'
                                  );

    $this->_init($init, $where);
  }
  
  function genFilter()
  {
    $par_id  = FormUtil::getPassedValue ('par_id', null, 'GET');

    $wheres = array();
    if ($par_id && intval($par_id))
    $wheres[] = " pol_par_id =".$par_id;
    return implode(' AND ', $wheres);
  }

}